import { useState } from 'react';
import Myrequest from './Myrequest';
import Mysale from './Mysale';
import { StyleSheet, Button, View, Text,ImageBackground } from 'react-native';

const MyRelease = ({ navigation }) => {
    const [isClick, setisClick] = useState(true)
    const [selectTab, setSelectTab] = useState(true);

    return (
        <View style={{ flex: 1 }}>
            <ImageBackground source={require('../img/bgimg.jpg')} style={styles.bgimg}>
                <View style={{ marginTop: 20 }}>
                    <View style={{ width: "50%", marginLeft: "20%", flexDirection: "row" }}>
                        <Text
                            style={{
                                fontSize: 20,
                                width: '45%',
                                height: 50,
                                borderRadius: 5,
                                backgroundColor: isClick ? "orange" : "lightgrey",
                                textAlign: "center",
                                verticalAlign: "middle"
                            }}
                            onPress={() => { setisClick(true) }}
                        >
                            需求列表
                        </Text>
                    </View>
                    <View style={{ width: "50%", marginLeft: "58%", flexDirection: "row", marginTop: "-11%" }}>
                        <Text
                            style={{
                                fontSize: 20,
                                width: '45%',
                                height: 50,
                                borderRadius: 5,
                                backgroundColor: isClick ? 'lightgrey' : "orange",
                                textAlign: "center",
                                verticalAlign: "middle"
                            }}
                            onPress={() => { setisClick(false) }}
                        >
                            出租物品
                        </Text>
                    </View>
                </View>
                <View>
                    {
                        isClick
                            ? <Mysale />
                            : <Myrequest />
                    }
                </View>
            </ImageBackground>
        </View>
    );
}

const styles = StyleSheet.create({
    bgimg:{
        flex: 1,
        resizeMode: "cover",
    },
});

export default MyRelease 